package com.google.devrel.example.android.protips.view;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.widget.ImageView;

public class MovingShapeView extends ImageView {
	
	private Paint paint = new Paint();
	private int cx = 0;
	private int cy = 0;

	public MovingShapeView(Context context) {
		super(context);
		
		paint.setARGB(0xff, 0xff, 0x0, 0x0);		
	}

	@Override
	protected void onDraw(Canvas canvas) {
		super.onDraw(canvas);
		//
		if (canvas!=null)
		{
			canvas.drawRect(cx, cy, cx+10, cy+10, paint);

			invalidate();
			//invalidate(cx, cy, cx+20, cy+20);

			cx += 10;
			if (cx>400)
			{
				cy += 10;
				cx = 0;
			}
			
			//invalidate(cx, cy, cx+10, cy+10);
			//invalidate(cx-10, cy-10, cx+10, cy+10);
		}
	}

}
